student_grades = []

def record_grade():
    name = input("学生姓名: ")
    stu_id = input("学号: ")
    course = input("课程: ")
    score = float(input("成绩: "))
    student_grades.append({
        "name": name,
        "stu_id": stu_id,
        "course": course,
        "score": score
    })
    print("✅ 成绩已记录")

def query_grade():
    query_type = input("查询方式 (姓名/学号): ")
    keyword = input("关键词: ")
    results = [g for g in student_grades if g[query_type] == keyword]
    if results:
        for res in results:
            print(f"{res['name']} | {res['stu_id']} | {res['course']} | {res['score']}")
    else:
        print("❌ 未找到记录")

def main():
    while True:
        print("\n=== 学生成绩管理系统 ===")
        print("1. 记录成绩")
        print("2. 查询成绩")
        print("3. 退出")
        choice = input("选择操作: ")
        if choice == "1":
            record_grade()
        elif choice == "2":
            query_grade()
        elif choice == "3":
            break
        else:
            print("❌ 无效选择")

if __name__ == "__main__":
    main()
#修改修改